import { useDidHide, useDidShow } from '@tarojs/taro';
import React, { useEffect } from 'react';
import 'taro-ui/dist/style/index.scss';
// import counterStore from './store/counter';
import './app.scss';
import { registerGlobalModules } from './di';
import { Login } from './model/login/Login';
import { Socket } from './model/socket/Socket';
import { useInjectable } from './unit/hooks/use-di';

function App(props) {
  registerGlobalModules();
  const socket = useInjectable(Socket);
  const login = useInjectable(Login);

  useEffect(() => {
    socket.init();
  }, [socket]);

  useEffect(() => {
    console.log('获取登录状态');
    login.index();
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);

  // 对应 onShow
  useDidShow(() => {});

  // 对应 onHide
  useDidHide(() => {});

  return (
    // 在入口组件不会渲染任何内容，但我们可以在这里做类似于状态管理的事情
    <div>
      {/* props.children 是将要被渲染的页面 */}
      {props.children}
    </div>
  );
}

export default App;
